package com.lyf.learn.atsgg.spring.jdbctemplate;

import com.lyf.learn.atsgg.spring.ioc.dao.UserDao;
import com.lyf.learn.atsgg.spring.jdbctemplate.dao.JdbcTestDao;
import com.lyf.learn.atsgg.spring.jdbctemplate.dao.JdbcTestDaoImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @AUTHOR LYF
 * @DATE 2022/5/26
 * @VERSION 1.0
 * @DESC
 */
public class MainApp {
    public static void main(String[] args) {
        ApplicationContext context
                =new ClassPathXmlApplicationContext("beans/DataSource.xml");
        String[]strings = context.getBeanDefinitionNames();
        for(String str:strings){
            System.out.println(str);
        }

        // 转型问题--
        // UserDao userDao = (JdbcTestDaoImpl) context.getBean("jdbcTestDaoImpl");
       // userDao.add();
        JdbcTestDao jdbcTestDao = context.getBean(JdbcTestDaoImpl.class);
        jdbcTestDao.addUser();

    }
}
